<template>
  <view class="daily-challenge-container setting-popup">
    <button @click="emitClose" style="position:absolute;right:20rpx;top:20rpx;z-index:10;">关闭</button>
    <!-- <image src="/static/daily-challenge.png" mode="widthFix" class="challenge-img" /> -->
    <view class="content">
      <view class="left">
        <view class="title">今日排行榜</view>
        <view v-for="(item, idx) in rankList" :key="idx" class="rank-item">
          <view>{{ idx + 1 }}. {{ item.name }} - {{ item.score }}分</view>
        </view>
      </view>
      <view class="right">
        <button @click="startChallenge">开始挑战</button>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue'
const emit = defineEmits(['close'])
const emitClose = () => emit('close')

const rankList = ref([
  { name: '玩家A', score: 120 },
  { name: '玩家B', score: 110 },
  { name: '玩家C', score: 100 }
])

const startChallenge = () => {
  uni.navigateTo({ url: '/pages/challenge/challenge' })
}
</script>

<style scoped>
.daily-challenge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40rpx 0;
}
.setting-popup {
  background: #fff;
  border-radius: 20rpx;
  box-shadow: 0 8rpx 32rpx rgba(0,0,0,0.18);
  padding: 40rpx 0;
  min-width: 600rpx;
  min-height: 400rpx;
  position: relative;
  z-index: 1002;
  opacity: 1;
}
.challenge-img {
  width: 80vw;
  margin-bottom: 40rpx;
}
.content {
  display: flex;
  flex-direction: row;
  width: 90vw;
  justify-content: space-between;
}
.left {
  width: 50vw;
}
.right {
  width: 30vw;
  display: flex;
  align-items: center;
  justify-content: center;
}
.title {
  font-size: 36rpx;
  margin-bottom: 20rpx;
}
.rank-item {
  font-size: 28rpx;
  margin-bottom: 10rpx;
}
button {
  width: 28vw;
  height: 80rpx;
}
</style> 